import threading
import time

# 气瓶
from Fpq.Xnq.Qi_ping import Qip1, Qip2, XnqX1, XnqX2
# 传动带
from Fpq.Bengzu.Bz_Chuandd import Cdd
# 主泵安全阀
from Fpq.Bengzu.Bz_zhuanquanfa import zhuaq
# 副泵安全阀
from Fpq.Bengzu.Bz_fuanquanfa import fuaq
# 压力开关
from Fpq.Bengzu.Bz_yalikaiguan import yalioff
# # 高压过滤
from Fpq.Bengzu.Bz_gaoyaguolu import check_filter_blockage
# # 泵凡尔泄露
from Fpq.Bengzu.Bz_fanerxielou import check_pump_valve_leakage
# # 缓冲
from Fpq.Bengzu.Bz_huanchong import huanchong
# # 管会调压阀
from Fpq.Guanhui.Gh_wannegtiaoyafa import guanhui
# # 面板指示灯
from Fpq.MianBan.Mb_zsd import MianB_huanxiang_fa
# # 管汇卡阻
from Fpq.Guanhui.Gh_diancifakz import check_valves_and_cylinders
# 清洁剂
from Fpq.Guanhui.Gh_qingjieji import Youqj
# 管汇-万能、闸板等功能动作不到位
from Fpq.Guanhui.Gh_budaowei import monitor_process
# 管汇-液缸串漏
from Fpq.Guanhui.Gh_yegangcl import ye_gang_chuan_lou

# 定义线程任务的通用函数，添加循环和时间间隔
def threaded_task(funcs, interval):
    while True:
        for func in funcs:
            func()
        time.sleep(interval)


# 3 秒任务列表
three_second_tasks = [Qip1, Qip2, XnqX1, XnqX2, Cdd, zhuaq, fuaq, yalioff, check_filter_blockage, huanchong, guanhui, MianB_huanxiang_fa, check_valves_and_cylinders, Youqj]
# 30 秒任务列表
thirty_second_tasks = [check_pump_valve_leakage]
second_task=[monitor_process]
second_task2=[ye_gang_chuan_lou]

# 创建线程
thread_3s = threading.Thread(target=lambda: threaded_task(three_second_tasks, 3))
thread_30s = threading.Thread(target=lambda: threaded_task(thirty_second_tasks, 30))
thread_60s = threading.Thread(target=lambda: threaded_task(second_task, 60))
thread2_60s = threading.Thread(target=lambda: threaded_task(second_task2, 60))

# 启动所有线程
thread_3s.start()
thread_30s.start()
thread_60s.start()
thread2_60s.start()

# 等待所有线程完成（由于while True循环，线程不会结束）
thread_3s.join()
thread_30s.join()
thread_60s.join()
thread2_60s.join()